1. Using ModelFlow with World Bank models#

The ModelFlow python package has been developed to solve a wide range of models, see the ModelFlow github IbHansen/ModelFlow web site for working examples of the Solow Model, the United States’ Federal REserve FRB/US model and others.

The package has been substantially expanded to include special features that enable it to work with World Bank models originally developed in EViews using the EViews Model Object for simulation. Although derived from these EViews models, the models available on the World Bank web site and through the mechanisms outlined below are pure python models and use ModelFlow and various python libraries for solution visualization and data management.

This chapter illustrates how to access these models, how to load them into a ModelFlow Anaconda environment on your computer, and how to perform a variety of simulations.

Warning

To be updated when final storage for models is sorted.

In this chapter - Using ModelFlow with World Bank Models

This chapter demonstrates how to effectively use ModelFlow with publicly available World Bank macroeconomic models. Key points include:

  • Available Models:

    • Access a range of pre-built World Bank models tailored for macroeconomic analysis.

    • Publicly available models can be loaded and customized in ModelFlow.

  • Setup and Workflow:

    1. Prepare the Python environment and install ModelFlow.

    2. Load the World Bank model and associated datasets.

    3. Use ModelFlow’s analytical methods to explore and interpret results.

This chapter provides a foundation for leveraging World Bank models in ModelFlow to perform detailed macroeconomic simulations and analyses.

1.1. Publicly available World Bank models for use with ModelFlow#

Several World Bank macrostructural models are currently available for download and use with ModelFlow (more will be added over time). The available models include:

  • Indonesia (Annual model with Climate features)

  • Nepal (Annual model with Climate features)

  • Croatia (Quarterly model)

  • Iraq (Annual model)

  • Uganda (Annual model with climate features)

  • Bolivia (Annual model)

  • Pakistan (Annual model with climate features)

Each of these models has been developed as part of the outreach work of the World Bank. The basic modeling framework of each of these models is outlined in Burns et al. [2019] with individual models having specific extensions reflecting features of the individual country and the questions for which the model was designed to respond. The approach for the models with climate features is laid out in Burns et al. [2021], although several additional features are included in some of these models that have not yet been documented.

As additional models are released they will be made available using the mechanism described below.

model.Worldbank_Models()

Avaiable notebooks

                  Indonesia
                            Indonesia readme
                            StandardShocks
                           Indonesia\OtherJupyterNotebooks
                                     idn electricity tax shock
                                     idn oil price shock
                  Nepal
                            Nepal readme
                            npl oil price shock 2 models
                            npl oil price shock
                            StandardShocks
                  Pakistan
                            Pakistan readme
                            ScenarioAnalysis
                            StandardShocks
                            Targeting

1.1.1. WorldbankModels() Options#

The model.Worldbank_Models() method includes several options, which affect the way the download of the models is executed.

1.1.1.1. The destinationoption#

To change the directory to which the files are downloaded the destination parameter can be set (by default it points to ./WorldBankModels).

model.Worldbank_Models('./mydirectory') would instead download the githhub repository to a directory called mydirectory below the location from which the command was executed. Note: For security reasons, the destination option will not accept a location that is above the directory from which it is executed.

1.1.1.2. The silent option#

By default the silent option is set to True. Setting it to False generates a more verbose indication of the directories and files downloaded and erased (of any).

1.1.1.3. Options controlling the treatment of existing files in the download directory#

option

default

Level of aggression

Action

reset

False

\(\color{red}{Maximum}\)

reset=True will cause the entire contents of the destination directory (WorldbankModels by default) to be deleted and replaced with the contents of the World Bank github repository

replace

False

\(\color{orange}{Medium}\)

replace=True will replace any file in the local store that also exists on the World Bank github site with the version on the World Bank site.

replace

False

\(\color{green}{Lowest}\)

replace=False will not change or delete any files on the user’s store. Only files that exist on the World Bank web site (and not on the local copy) will be downloaded.

1.1.1.4. Options to change the repository that is downloaded#

It is possible to choose a repository other than the World Bank site to be downloaded, although the use case for this option is limited. A user that wishes to do this can specify the repository to be downloaded by setting the following options

option

Default value

Explanation

owner

WorldBank

Name of the owner of the github repository to be downloaded

repo_name

MFMod-ModelFlow

The name of the repository

branch

main

The branch to downloaded.

For example to download some of the non-World Bank ModelFlow models from the ModelFlow github repository available, a user could execute

`model.Worldbank_Models(owner=’IbHansen’,repo_name = ‘wb-repos’,destination=’./ModelFlowModels’, silent=False , reset= False, replace = True )

Menu to start notebooks in subfolders
help(model.Worldbank_Models)
Help on function Worldbank_Models in module modelclass:

Worldbank_Models(owner: str = 'worldbank', repo_name: str = 'MFMod-ModelFlow', branch: str = 'main', destination='./WorldbankModels', go=True, silent=True, replace=False)
    Download an entire GitHub repository and extract it to a specified location.

    Parameters:
      owner: The owner of the GitHub repository.
      repo_name: The name of the repository.
      branch: The branch to download.
      destination: The local path where the repository should be extracted.
      go: display toc of notebooks
      silent: keep silent

    Returns:
      A message indicating whether the download was successful or not.

1.2. .display_toc() method#

The .display_toc() method displays a list of the directories and files included in the subfolder to which the World Bank models were previously downloaded.

Menu to start notebooks in subfolders